# CPU.py
import random
from RunTime import RunTime

CPU_num_set = set()  # 初始化为空集合

def get_input():
    max_num = int(input("压榨原理:猜测检索大量数字\n输入压榨力度(int):"))  # 获取压榨力度最大值
    return max_num

def Squeeze_the_CPU(max_num):
    global CPU_num_set
    guess_num = random.randint(0, max_num)  # 随机正确数字，以终止循环
    CPU_num_set = set(range(0, max_num + 1))  # 使用集合存储可猜数字
    while True:
        CPU_guess_num = random.choice(tuple(CPU_num_set))  # 将集合转换为元组以允许随机选择
        if CPU_guess_num != guess_num:
            print(f"数字:{CPU_guess_num},错误")
            CPU_num_set.remove(CPU_guess_num)
        else:
            print(f"数字:{CPU_guess_num},正确")
            return True

@RunTime        
def main():
    max_num = get_input()
    Squeeze_the_CPU(max_num)